package jp.test;

import java.util.Vector;

import org.cybergarage.upnp.Device;

public class GroupControllerList extends Vector<GroupController> {

	public Device getDevice(int n){
		return get(n).getDev();
	}
	
	public GroupController getGroupController(int n){
		return get(n);
	}
	
	public int getBiggest(GroupControllerList gcList){
		int biggestVal = 0;
		
		int nSize = size();
		//count biggest
		for(int i=0; i<nSize; i++){
			GroupController gc = get(i);
			int currentSize = gc.getGroupSize();
				
			if(currentSize > biggestVal){
			
				biggestVal = currentSize;
				gcList.clear();
				gcList.add(gc);
			}else if(currentSize == biggestVal){
				
				gcList.add(gc);
			}else{ //currnetSize < biggest
				
			}
		}
		
		return gcList.size();
		
	}
	
	public int getFastestCPU(GroupControllerList gcList){
		int fastest = 0;
		
		int nSize = size();
		
		for(int i=0; i<nSize; i++){
			GroupController gc = get(i);
			int currentSpeed = gc.getCpuSpeedMHz();
			
			if(currentSpeed > fastest){
				fastest = currentSpeed;
				gcList.clear();
				gcList.add(gc);
			}else if(currentSpeed == fastest){
				gcList.add(gc);
			}else{
				
			}
		}
		
		return gcList.size();
	}
	
	public int getBiggestFreeMem(GroupControllerList gcList){
		long biggest = 0;
		
		int nSize = size();
		
		for(int i=0; i<nSize; i++){
			GroupController gc = get(i);
			long currentFreemem = gc.getFreeMemoryKB();
			
			if(currentFreemem > biggest){
				biggest = currentFreemem;
				gcList.clear();
				gcList.add(gc);
			}else if(biggest == currentFreemem){
				gcList.add(gc);
			}else{
				
			}
		}
		
		return gcList.size();
	}
}
